home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.sprintlink.net!mv!usenet
- From: ENGR@GSSI.MV.COM (Michael Furman)
- Subject: Re: Object with Interrupt Service Routine
- Message-ID: <DL8B3G.MuB@mv.mv.com>
- Mime-Version: 1.0
- Organization: GSSI
- Date: Mon, 15 Jan 1996 15:30:51 GMT
- References: <4d6imm$okq@newsbf02.news.aol.com>
- X-Newsreader: WinVN 0.93.10
- X-Nntp-Posting-Host: gssi.mv.com
-
- In article <4d6imm$okq@newsbf02.news.aol.com>, awhang8367@aol.com says...
- >
- > I have been struggling to create an object that handles hardware
- >interrupt directly. Particularly with the setvect function as it takes in
- >pointers to interrupts
- >^^^^^^^^^
- >and not to objects. Two things I can do (and I have accomplished ther
- >former):
- >
- > 1) Use an interrupt service routine to call the object.
-
- If you mean "call nonstatic member function of the object" - why not. I see
- only two problems:
- 1. - how to obtain pointer to the instance that corresponds to this
- interrupt.
- 2. - size of current stack. If it is asynchronous interrupt - it may
- happend at any time and nobody can garantee you that you have a stack space
- big enough for executing your function.
-
- > 2) directly write the address of the member function to the Interrupt
- >vector table
- You can, but only for static member function (and it probably should be
- declared with "interrupt" keyword - but it, like other staff, highly CPU/OS
- dependable). To call nonstatic member function you must supply pointer to the
- instance of your class (my problem "1").
- >
- > Both implementations seems to be very clumsy. Does anyone know of a
- >good way of doing it? Any pointer or email interrupt will be greatly
- >appreciated.
-
- You have not defined exactly what do you need. I can suppose 2 variants:
-
- 1. Just one interrupt handling. In this case you can use static
- interrupt member function and static pointer to instance of your class. This
- function can call some nonstatic member function using this pointer if you
- need that. And you will probably need assembler code to switch to new stack
- frame and to restore old stack frame.
-
- 2. You need to handle more than one interrupt. This case is more complicated:
- you need to hide somewere pointers to class instances for each interrupt.
- There is no place in interrupt table - and the only way I can see (and use) -
- reserve space in class and put there for each instance a small assemler stub,
- which load pointer to this instance to some register and transfer control to
- common ISR static function.
-
- This works for PC/MSDOS - the only thing wee need (I believe) - is the common
- address space for data and instructions, or at least ability to allocate
- and modify program memory (in that case stubs must be allocated there).
-
-
- --
- ---------------------------------------------------------------
- Michael Furman, (603)893-1109
- Geophysical Survey Systems, Inc. fax:(603)889-3984
- 13 Klein Drive - P.O. Box 97 engr@gssi.mv.com
- North Salem, NH 03073-0097 71543.1334@compuserve.com
- ---------------------------------------------------------------
-
-